package com.project.housesalesystem.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project.housesalesystem.bean.House;
import com.project.housesalesystem.mapper.HouseMapper;
import com.project.housesalesystem.service.HouseService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Map;
/**
 * 房源信息实现类
 *
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class HouseServiceImpl extends ServiceImpl<HouseMapper, House> implements HouseService {
    /*
     *  分页查询房源信息
     */
    @Override
    public IPage<House> getHousePage(Map<String, Object> params) {


        Page<House> page = new Page<>(Long.parseLong(params.get("pageNum")+""), Long.parseLong(""+params.get("pageSize")));

        // 查询数据
        Page<House> housePage = this.baseMapper.selectHousePage(page, params.get("keywords")+"");

        return housePage;
    }

    /*
     *  修改房源上下架状态
     */
    @Override
    public boolean updateHouseState(String state, long id) {
        return this.baseMapper.updateHouseState(state, id);
    }
}
